home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
oper_sys
/
amber
/
amber.lha
/
ObjectList.h
< prev
next >
Wrap
C/C++ Source or Header
|
1991-04-25
|
2KB
|
47 lines
#ifndef _ObjectList_h
#define _ObjectList_h
#include "NamedObject.h"
//
// ListedObjects live in doubly-linked lists called ObjectLists. The class
// ObjectList and the base class ListedObject define the data and functions
// required for maintenance of the lists. Functions are provided to treat
// the list as a queue. Actual object contents are the responsibility of a
// derived class of ListedObject.
//
// Note that ListedObjects are NamedObjects. The two classes are orthogonal
// and many ListedObjects will not need the characteristics of NamedObjects,
// but we don't have multiple inheritance so we just do what we can.
//
// Warning: Threads are ListedObjects. The offsets of fields in class Thread
// are known to asm code in Switch.s and are dependent upon the length
// of the ListedObject structure. If you change this class you must fix the
// offsets in Switch().
//
struct ListedObject : public NamedObject {
ListedObject *next;
ListedObject *prev;
ListedObject(int t=0, char* n=0);
};
//
// ObjectList probably should have inline versions of Append and Get
// at least, for use with the thread ready list.
//
class ObjectList : public NamedObject {
ListedObject *head;
ListedObject *tail;
public:
ObjectList(ListedObject* head = 0);
ListedObject* Get(); // from head of queue
ListedObject* LookAt(); // non-destructive Get
void Append(ListedObject* ol); // to end of queue
void Prepend(ListedObject* ol); // to head of queue
int Remove(ListedObject* ol); // remove arbitrary element
int Empty()
{ return head == 0; }
virtual void Print(ostream& = cout);
};
#endif _ObjectList_h